<html lang="en">

<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Java.lang---interface---Cloneable,Thread.UncaughtExceptionHandler,Iterable&lt;T&gt;,Runnable - bravo</title>
<link rel="shortcut icon" href="https://JoyZgq.github.io/favicon.ico">
<link href="https://cdn.jsdelivr.net/npm/remixicon@2.2.0/fonts/remixicon.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.7.2/animate.min.css">
<link rel="stylesheet" href="https://JoyZgq.github.io/media/css/tailwind.css">
<link rel="stylesheet" href="https://JoyZgq.github.io/styles/main.css">
<link rel="alternate" type="application/atom+xml" title="Java.lang---interface---Cloneable,Thread.UncaughtExceptionHandler,Iterable&lt;T&gt;,Runnable - bravo - Atom Feed" href="https://JoyZgq.github.io/atom.xml">


  <script async src="https://www.googletagmanager.com/gtag/js?id=UA-164181119-1"></script>
  <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
  
    gtag('config', 'UA-164181119-1');
  </script>
    

  <meta name="description" content="Cloneable

类实现Cloneable接口，以向Object.clone()方法指示该方法对该类的实例进行字段到字段复制是合法的。

  在未实现Cloneable接口的实例上调用Object的clone方法会导致抛出异常Clone..." />
  <meta property="og:title" content="Java.lang---interface---Cloneable,Thread.UncaughtExceptionHandler,Iterable&lt;T&gt;,Runnable - bravo">
  <meta property="og:description" content="Cloneable

类实现Cloneable接口，以向Object.clone()方法指示该方法对该类的实例进行字段到字段复制是合法的。

  在未实现Cloneable接口的实例上调用Object的clone方法会导致抛出异常Clone..." />
  <meta property="og:type" content="articles">
  <meta property="og:url" content="https://JoyZgq.github.io/post/Cex-T6UeQ/" />
  <meta property="og:image" content="https://JoyZgq.github.io/post-images/Cex-T6UeQ.webp">
  <meta property="og:image:height" content="630">
  <meta property="og:image:width" content="1200">
  <meta name="twitter:title" content="Java.lang---interface---Cloneable,Thread.UncaughtExceptionHandler,Iterable&lt;T&gt;,Runnable - bravo">
  <meta name="twitter:description" content="Cloneable

类实现Cloneable接口，以向Object.clone()方法指示该方法对该类的实例进行字段到字段复制是合法的。

  在未实现Cloneable接口的实例上调用Object的clone方法会导致抛出异常Clone...">
  <meta name="twitter:card" content="summary_large_image">
  <link rel="canonical" href="https://JoyZgq.github.io/post/Cex-T6UeQ/">

  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.css">
 
  
    <link rel="stylesheet" href="https://JoyZgq.github.io/media/css/prism-github.css">
  

  
</head>

<body>
  <div class="antialiased flex flex-col min-h-screen" id="app">
    <a href="https://JoyZgq.github.io" class="fixed top-0 left-0 mt-4 bg-black text-white dark:text-gray-700 dark:bg-yellow-50 dark:hover:bg-black dark:hover:text-white inline-flex p-2 pl-8 hover:text-gray-700 hover:bg-yellow-50 font-bold z-10 transition-fast animated fadeInLeft">
      bravo
    </a>
    <div class="max-w-4xl w-full mx-auto">
      <div class="shadow-box bg-white dark:bg-gray-600 rounded-lg pt-32 md:pt-64 px-4 md:px-8 pb-8 animated fadeIn mb-8">
        <h1 class="text-5xl font-semibold leading-normal pb-8 mb-8 border-b-8 border-gray-700">
          Java.lang---interface---Cloneable,Thread.UncaughtExceptionHandler,Iterable&lt;T&gt;,Runnable
        </h1>
        
          <img src="https://JoyZgq.github.io/post-images/Cex-T6UeQ.webp" alt="Java.lang---interface---Cloneable,Thread.UncaughtExceptionHandler,Iterable&lt;T&gt;,Runnable" class="block w-full mb-8">
        
        <div class="mb-8 flex flex-wrap">
          <div class="text-gray-400 text-sm mr-4">2019-04-09 · 3 min read</div>
          
        </div>
        <div class="markdown mb-8" v-pre>
          <h3 id="cloneable">Cloneable</h3>
<blockquote>
<p>类实现Cloneable接口，以向Object.clone()方法指示该方法对该类的实例进行字段到字段复制是合法的。</p>
</blockquote>
<p>  在未实现Cloneable接口的实例上调用Object的clone方法会导致抛出异常<code>CloneNotSupportedException</code> 。<br>
  按照惯例，实现此接口的类应使用公共方法覆盖Object.clone （受保护）。 有关重写此方法的详细信息，请参见Object.clone() 。<br>
  注意，此接口不包含clone方法。 因此，仅仅通过实现该接口的事实来克隆对象是不可能的。 即使反射调用clone方法，也无法保证它会成功。</p>
<hr>
<h3 id="threaduncaughtexceptionhandler">Thread.UncaughtExceptionHandler</h3>
<blockquote>
<p>这是一个功能接口，因此可以用作lambda表达式或方法引用的赋值目标。</p>
</blockquote>
<p>  Thread由于未捕获的异常而突然终止时调用的处理程序接口。当一个线程要终止由于未捕获到异常的Java虚拟机将查询线程其<code>UncaughtExceptionHandler</code>使用Thread.getUncaughtExceptionHandler() ，将调用处理程序的uncaughtException方法，将线程和异常作为参数。 如果一个线程一直没有其UncaughtExceptionHandler明确设置，那么它ThreadGroup对象充当其UncaughtExceptionHandler 。 如果ThreadGroup对象对处理异常没有特殊要求，则可以将调用转发给default uncaught exception handler 。</p>
<hr>
<h3 id="runnable">Runnable</h3>
<blockquote>
<p>这是一个功能接口，因此可以用作lambda表达式或方法引用的赋值目标。</p>
</blockquote>
<p>  Runnable接口应由任何其实例由线程执行的类实现。 该类必须定义一个名为run的无参数的方法。<br>
此接口旨在为希望在活动时执行代码的对象提供通用协议。 例如， Runnable由类Thread实现。 活动只是意味着一个线程已经启动但尚未停止。</p>
<p>  此外， Runnable提供了一个类活动而不是Thread 。 实现Runnable类Thread通过实例化Thread实例并将其自身作为目标传递而无需子类化Thread 。 在大多数情况下，如果您只打算覆盖run()方法而不使用其他Thread方法，则应使用Runnable接口。 这很重要，因为除非程序员打算修改或增强类的基本行为，否则不应对类进行子类化。</p>
<hr>
<h3 id="iterablet">Iterable<T></h3>
<blockquote>
<p>实现此接口允许对象成为增强型 for语句的目标（有时称为“for-each循环”语句）。<strong>T - 迭代器返回的元素类型</strong></p>
</blockquote>
<table>
<thead>
<tr>
<th style="text-align:left">变量和类型</th>
<th style="text-align:left">方法</th>
<th style="text-align:left">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>default void</code></td>
<td style="text-align:left"><code>forEach(Consumer action)</code></td>
<td style="text-align:left">对 <code>Iterable</code>每个元素执行给定操作，直到处理 <code>Iterable</code>所有元素或操作引发异常。</td>
</tr>
<tr>
<td style="text-align:left"><code>Iterator</code></td>
<td style="text-align:left"><code>iterator()</code></td>
<td style="text-align:left">返回 <code>T</code>类型的元素的迭代器。</td>
</tr>
<tr>
<td style="text-align:left"><code>default Spliterator</code></td>
<td style="text-align:left"><code>spliterator()</code></td>
<td style="text-align:left">在<a href="https://joyzgq.github.io/post/bqpsTtCTf/">Iterable</a>描述的元素上创建<code>Iterable</code> 。</td>
</tr>
</tbody>
</table>
<h4 id="foreach">forEach</h4>
<p>  如果指定了该顺序，则按迭代顺序执行操作。 操作抛出的异常将转发给调用者。如果操作执行修改元素的基础源的副作用，则此方法的行为未指定，除非重写类已指定并发修改策略。</p>
<h4 id="spliterator">spliterator</h4>
<p>  在Iterable描述的元素上创建Iterable 。默认实现从iterable的Iterator创建early-binding Iterator , spliterator继承了iterable迭代器的fail-fast属性。<em>通常应该覆盖默认实现， 默认实现返回的分裂器具有较差的分割能<br>
力，未分级，并且不报告任何分裂器特征。 实现类几乎总能提供更好的实现。</em></p>

        </div>
        <!-- Share to Twitter, Weibo, Telegram -->
        <div class="flex items-center">
          <div class="mr-4 flex items-center">
            <i class="ri-share-forward-line text-gray-500"></i>
          </div>
          <div class="px-4 cursor-pointer text-blue-500 hover:bg-blue-100 dark:hover:bg-gray-600 inline-flex" @click="shareToTwitter">
            <i class="ri-twitter-line"></i>
          </div>
          <div class="px-4 cursor-pointer text-red-500 hover:bg-red-100 dark:hover:bg-gray-600 inline-flex" @click="shareToWeibo">
            <i class="ri-weibo-line"></i>
          </div>
          <div class="px-4 cursor-pointer text-indigo-500 hover:bg-indigo-100 dark:hover:bg-gray-600 inline-flex" @click="shareToTelegram">
            <i class="ri-telegram-line"></i>
          </div>
        </div>
      </div>

      

      
        <div id="vlaine-comment"></div>
      

      <footer class="py-12 text-center px-4 md:px-0" v-pre>
  Powered by <a href="https://github.com/getgridea/gridea" target="_blank">Gridea</a>  Made by  <a href="https://github.com/JoyZgq" target="_blank">zgq</a> 🎈❤❤❤🌹
</footer>
    </div>

    <!-- TOC Container -->
    <div class="fixed right-0 bottom-0 mb-16 mr-4 shadow w-8 h-8 rounded-full flex justify-center items-center z-10 cursor-pointer bg-white dark:bg-gray-500 dark:text-gray-200 hover:shadow-lg transition-all animated fadeInRight" @click="showToc = true">
      <i class="ri-file-list-line"></i>
    </div>

    <div class="fixed right-0 top-0 bottom-0 overflow-y-auto w-64 bg-white dark:bg-gray-800 p-4 border-l border-gray-100 dark:border-gray-600 z-10 transition-fast" :class="{ '-mr-64': !showToc }">
      <div class="flex mb-4 justify-end">
        <div class="w-8 h-8 inline-flex justify-center items-center rounded-full cursor-pointer hover:bg-gray-200 dark:hover:bg-gray-600 transition-fast" @click="showToc = false">
          <i class="ri-close-line text-lg"></i>
        </div>
      </div>
      <div class="post-toc-container">
        <ul class="markdownIt-TOC">
<li>
<ul>
<li>
<ul>
<li><a href="#cloneable">Cloneable</a></li>
<li><a href="#threaduncaughtexceptionhandler">Thread.UncaughtExceptionHandler</a></li>
<li><a href="#runnable">Runnable</a></li>
<li><a href="#iterablet">Iterable<T></a>
<ul>
<li><a href="#foreach">forEach</a></li>
<li><a href="#spliterator">spliterator</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>

      </div>
    </div>

    <!-- Back to top -->
    <div class="fixed right-0 bottom-0 mb-4 mr-4 shadow w-8 h-8 rounded-full flex justify-center items-center z-10 cursor-pointer bg-white hover:shadow-lg transition-all dark:bg-gray-500 dark:text-gray-200" @click="backToUp" v-show="scrolled">
      <i class="ri-arrow-up-line"></i>
    </div>
  </div>

  <!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
  <!-- Background of PhotoSwipe. 
        It's a separate element as animating opacity is faster than rgba(). -->
  <div class="pswp__bg">
  </div>
  <!-- Slides wrapper with overflow:hidden. -->
  <div class="pswp__scroll-wrap">
    <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
    <div class="pswp__container">
      <div class="pswp__item">
      </div>
      <div class="pswp__item">
      </div>
      <div class="pswp__item">
      </div>
    </div>
    <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
    <div class="pswp__ui pswp__ui--hidden">
      <div class="pswp__top-bar">
        <!--  Controls are self-explanatory. Order can be changed. -->
        <div class="pswp__counter">
        </div>
        <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
        <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
        <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
        <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
        <!-- element will get class pswp__preloader--active when preloader is running -->
        <div class="pswp__preloader">
          <div class="pswp__preloader__icn">
            <div class="pswp__preloader__cut">
              <div class="pswp__preloader__donut">
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
        <div class="pswp__share-tooltip">
        </div>
      </div>
      <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
      </button>
      <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
      </button>
      <div class="pswp__caption">
        <div class="pswp__caption__center">
        </div>
      </div>
    </div>
  </div>
</div>

  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <script src="https://JoyZgq.github.io/media/scripts/main.js"></script>
  
  <!-- Code Highlight -->
  
    <script src="https://JoyZgq.github.io/media/prism.js"></script>
    <script>
      Prism.highlightAll()
    </script>
  

  <script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>
  <script>
    //拿到预览框架，也就是上面的html代码
    var pswpElement = document.querySelectorAll('.pswp')[0];
    //定义图片数组变量
    var imgitems;
    /**
    * 用于显示预览界面
    * @param index 图片数组下标
    */
    function viewImg(index) {
      //其它选项这里不做过多阐述，详情见官网
      var pswpoptions = {
        index: parseInt(index, 10), // 开始幻灯片索引。0是第一张幻灯片。必须是整数，而不是字符串。
        bgOpacity: 0.7, // 背景透明度，0-1
        maxSpreadZoom: 3, // 缩放级别，不要太大
      };
      //初始化并打开PhotoSwipe，pswpElement对应上面预览框架，PhotoSwipeUI_Default为皮肤，imgitems为图片数组，pswpoptions为选项
      var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, imgitems, pswpoptions);
      gallery.init()
    }
    /**
    * 用于添加图片点击事件
    * @param img 图片元素
    * @param index 所属下标（在imgitems中的位置）
    */
    function addImgClick(img, index) {
      img.onclick = function() {
        viewImg(index)
      }
    }
    /**
    * 轮询所有图片，获取src、width、height等数据，加入imgitems，并给图片元素添加事件
    * 最好在onload中执行该方法，本站因放在最底部，所以直接初始化
    * 异步加载图片可在图片元素创建完成后调用此方法
    */
    function initImg() {
      //重置图片数组
      imgitems = [];
      //查找class:markdown 下的所有img元素并遍历
      var imgs = document.querySelectorAll('.markdown img');
      for (var i = 0; i < imgs.length; i++) {
        var img = imgs[i];
        //本站相册初始为loading图片，真实图片放在data-src
        var ds = img.getAttribute("data-src");
        //创建image对象，用于获取图片宽高
        var imgtemp = new Image();
        //判断是否存在data-src
        if (ds != null && ds.length > 0) {
          imgtemp.src = ds
        } else {
          imgtemp.src = img.src
        }
        //判断是否存在缓存
        if (imgtemp.complete) {
          var imgobj = {
            "src": imgtemp.src,
            "w": imgtemp.width,
            "h": imgtemp.height,
          };
          imgitems[i] = imgobj;
          addImgClick(img, i);
        } else {
          console.log('进来了2')
          imgtemp.index = i;
          imgtemp.img = img;
          imgtemp.onload = function() {
            var imgobj = {
              "src": this.src,
              "w": this.width,
              "h": this.height,
            };
            //不要使用push，因为onload前后顺序会不同
            imgitems[this.index] = imgobj
            //添加点击事件
            addImgClick(this.img, this.index);
          }
        }
      }
    }
    //初始化
    initImg();
  </script>
  
    <script type="application/javascript" src="https://unpkg.com/valine"></script>
<script type="application/javascript">
  new Valine({
    el: '#vlaine-comment',
    appId: 'Sy2gsMvGcPQl3gTGsqqYsHW6-gzGzoHsz',
    appKey: 'IpsgegiMUNgRg7l5BVXk6EXM',
    pageSize: 10,
    notify: false,
    avatar: 'mp',
    verify: true,
    placeholder: '可观来都来了，不妨评论一下🌹🐱‍👤',
    visitor: true,
    highlight: false,
    recordIP: true,
  })
</script>
  
  
</body>

</html>